'Animals AR Submission
Option Strict Off
imports System
imports PHSRAG.Insight21.Humans
imports PHSRAG.Insight21.BusinessObjects
imports FormsManagement = PHSRAG.Insight21.FormsManagement
imports System.Collections

module Script
    sub Main()
    
        ' cast RexParams to an AnimalsRexParams.
		
        Dim questionnaireAnswers As new ArrayList()
        Dim qV As FormsManagement.QuestionnaireVersion
        Dim questionnaireAnswer As FormsManagement.QuestionnaireAnswer

		questionnaireAnswers= currentProtVersion.QuestionnaireAnswers
		
		For Each questionnaireAnswer In questionnaireAnswers
    			
		    qV  = questionnaireAnswer.QuestionnaireVersion
    		
		    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		    '  Annual Review
		    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
		    
		    
		    ' Note: Default the status to "Active" per Robin, since Triennial Reviews
		    ' require a status in Rex, but there's no question for this.
		    rexParams.ProjectStatus = "Active"
		    
		    If (qV.Questionnaire.Name = "Annual Report") Then
			    Dim answers as new ArrayList()
			    answers = questionnaireAnswer.GetAnswers("Status") 
			    If (answers.Count > 0) Then
		            Dim status as FormsManagement.Answer = answers(0)
			        if status.Value = "ACT" then
				        rexParams.ProjectStatus = "Active"
			        else if status.Value = "NAY" then
				        rexParams.ProjectStatus = "Not Activated Yet"
			        else if status.Value = "COM" then
				        rexParams.ProjectStatus = "Completed"
			        else if status.Value = "CLOSE" then
				        rexParams.ProjectStatus = "Never Activated"				    				
			        end if
			    End If
			    
			    
			    'Usage" or "ComUse" would be populated in the "Animals Used" box, in the "Reported" 
			    answers = nothing
			    answers = questionnaireAnswer.GetAnswers("Usage") 
			    If (answers.Count > 0) Then
			        Dim animalsUsed as FormsManagement.Answer = answers(0)
			        rexParams.AnimalsReported = animalsUsed.Value
			    End If
			    
			    answers = nothing
			    answers = questionnaireAnswer.GetAnswers("ComUse") 
			    If (answers.Count > 0) Then
			        Dim animalsUsed as FormsManagement.Answer = answers(0)
			        rexParams.AnimalsReported = animalsUsed.Value
			    End If
			    
			    
			    '"Explain" and "ComExplain" should be entered in the "Notes" tab of Rex
			    answers = nothing
			    answers = questionnaireAnswer.GetAnswers("Explain")
			    If (answers.Count > 0) Then
			        Dim animalsUsed as FormsManagement.Answer = answers(0)
			        rexParams.AnnReviewNotes = animalsUsed.Value
			    End If
			    
			    answers = nothing
			    answers = questionnaireAnswer.GetAnswers("ComExplain")
			    If (answers.Count > 0) Then
			        Dim animalsUsed as FormsManagement.Answer = answers(0)
			        rexParams.AnnReviewNotes = animalsUsed.Value
			    End If
    			
		    End If
        Next
    end sub	
end module